<template>
    <div style="position:relative;height:400px;width:100%;">
        <tabList :result='scrollDatas' @getList='getHotLableBookInfo' />
        <div class="navbar">

            <div class="hotBook">
                <ul class="hotBookInfo">
                    <li v-for='(item,index) in currentList' :key='index'>
                        <img :src="baseImgUrl+item.image" alt="">
                        <div class="bookInfo">
                            <p class="bookName">{{item.bookName}}</p>
                            <p class="bookAuthor">{{item.authorName}}</p>
                            <p class="bookPrice">
                                <span class="price">¥{{item.price}}</span>
                                <span class='discount'>{{item.discount*10}}折</span>
                            </p>
                            <p class="desc">张嘉佳全新作品，写给离开我们的人，写给陪伴...</p>
                        </div>
                        <p class="btn">购买</p>
                    </li>

                </ul>
            </div>
            <p v-if="currentList.length=='0'" class="noneData">暂无数据</p>
        </div>

    </div>
</template>
<script>
import tabList from '../../components/newTabList/index'
export default {
    data() {
        return {
            scrollDatas: [],
            currentList: [],
            baseImgUrl: this.BaseUrlImg
        }
    },
    mounted() {
        console.log(this.$root.$mp.query) //获取页面传递过来的值
        let firstLevel = this.$root.$mp.query.keyWord
        this.getHotLableBookInfo(firstLevel)
        this.$http
            .post('/book/hotlable', {
                page: 1,
                pageSize: 10
            })
            .then(res => {
                this.scrollDatas = res.data.rows
            })
        // 展示导航
    },
    components: {
        tabList
    },
    methods: {
        getHotLableBookInfo(id) {
            this.$http
                .post('/book/bylable', {
                    label: id,
                    page: 1,
                    pageSize: 10
                })
                .then(res => {
                    this.hotBookLabel = res.data.rows
                })
        },
        handleChangeScroll(val) {
            this.current_scroll = val.mp.detail.key
        },
        buyNow() {
            console.log('123')
            wx.navigateTo({
                url: '../booksBuy/main'
            })
        }
    }
}
</script>
<style lang="scss" scoped>
.hotBookInfo {
    padding: 0 18rpx;
    li {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #eee;
        padding: 30rpx 0;
        img {
            width: 166rpx;
            height: 266rpx;
            border-radius: 5px;
        }
        .bookInfo {
            width: 334rpx;
            .bookName {
                font-size: 16px;
                color: #202020;
            }
            .bookAuthor {
                font-size: 14px;
                color: #202020;
                margin-top: 20rpx;
            }
            .bookPrice {
                font-size: 12px;
                margin-top: 20rpx;
                .price {
                    font-size: 12px;
                    color: #999;
                    margin-right: 30rpx;
                }
                .discount {
                    color: #fe6270;
                }
            }
            .desc {
                margin-top: 20rpx;
                word-break: break-all;
                word-wrap: break-word;
                color: #8290a3;
                font-size: 14px;
            }
        }
        .btn {
            width: 130rpx;
            height: 64rpx;
            border: 1px solid #c78550;
            color: #c78550;
            line-height: 64rpx;
            text-align: center;
            border-radius: 5px;
        }
    }
}
.noneData {
    font-size: 12px;
    color: #999;
    width: 100%;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
</style>

